//
//  ViewController.m
//  GRJTolCayFrwk
//
//  Created by apple on 2017/2/28.
//  Copyright © 2017年 Global Barter. All rights reserved.
//

#import "ViewController.h"
#import "UIImage+GRJImage.h"
#import "UIColor+GRJColor.h"
#import "UITextField+GRJTextField.h"
#import "UIButton+GRJButton.h"


#import "MBProgressHUDViewController.h"

#import "UIViewController+GRJViewController.h"

#import "GRJJDStatusBarNotificationViewController.h"

#import "GRJBlocksKitViewController.h"

#import "GRJMasonryViewController.h"

#import "GRJSDWebimageViewController.h"

#import "RegexKitLiteViewController.h"

#import "GRJSDCAlertViewViewController.h"

NSString *ID =@"cellID";

@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITextField *textF;

@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,copy)NSArray *cellArray;

@end

@implementation ViewController

-(NSArray *)cellArray{
    if (_cellArray == nil) {
        
        _cellArray = @[@"MBProgressHUD",@"TPKeyboardAvoiding",@"JDStatusBarNotification",@"BlocksKit",@"Masonry",@"SDWebimage",@"RegexKitLite",@"SDCAlertView"];
    }
    
    return _cellArray;
}



- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"首页";
    
    
    [self setUpTableView];
    
    
}

-(void)setUpTableView{
    self.tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    
    _tableView.delegate = self;
    _tableView.dataSource = self;
    
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:ID];
    
    
    [self.view addSubview:_tableView];
}
#pragma mark - UITableViewDataSource

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.cellArray.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    
    cell.textLabel.text = _cellArray[indexPath.row];
    
    return cell;
}

#pragma mark - UITableViewDelegate

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row==0) {
        MBProgressHUDViewController *hudViewVC = [[MBProgressHUDViewController alloc]init];
        [self.navigationController pushViewController:hudViewVC animated:YES];
    }else if (indexPath.row==1){
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"GRJTPKeyStoryboard" bundle:nil];
        UIViewController *tabVC = [storyboard instantiateInitialViewController];
        [self.navigationController pushViewController:tabVC animated:YES];
        
    }else if (indexPath.row==2){
        GRJJDStatusBarNotificationViewController *jDVC = [[GRJJDStatusBarNotificationViewController alloc]init];
        [self.navigationController pushViewController:jDVC animated:YES];
    }else if (indexPath.row==3){
        GRJBlocksKitViewController *blockVC = [[GRJBlocksKitViewController alloc]init];
        [self.navigationController pushViewController:blockVC animated:YES];
    }else if (indexPath.row==4){
        GRJMasonryViewController *masonry = [[GRJMasonryViewController alloc]init];
        [self.navigationController pushViewController:masonry animated:YES];
    }else if (indexPath.row==5){
        GRJSDWebimageViewController *webImage = [[GRJSDWebimageViewController alloc]init];
        [self.navigationController pushViewController:webImage animated:YES];
    }else if (indexPath.row==6){
        RegexKitLiteViewController *webImage = [[RegexKitLiteViewController alloc]init];
        [self.navigationController pushViewController:webImage animated:YES];
    }else if (indexPath.row==7){
        GRJSDCAlertViewViewController *webImage = [[GRJSDCAlertViewViewController alloc]init];
        [self.navigationController pushViewController:webImage animated:YES];
    }
}



-(void)setUpOneTF{
    UITextField *textF = [[UITextField alloc]init];
    textF.frame = CGRectMake(100, 200, 200, 44);
    
    textF.placeholder = @"请输入文字";
    [self.view addSubview:textF];
    
    
    
}
-(void)setImageView{
    UIImageView *imageV = [[UIImageView alloc]init];
    imageV.image = [UIImage grj_circleImageWithName:nil image:[UIImage imageNamed:@"yingzhiren"] borderWidth:55 borderColor:[UIColor whiteColor]];
    
    imageV.frame = CGRectMake(100, 100, 100, 200);
    
    imageV.backgroundColor = [UIColor blackColor];
    [self.view addSubview:imageV];
    
}

-(void)setTextField{
    UITextField *textF = [[UITextField alloc]init];
    textF.frame = CGRectMake(100, 100, 200, 40);
    textF.text =@"nishusdfwd";
    
    
    self.textF = textF;
    [self.view addSubview:textF];
    
    
    
    
}

-(void)setButton{
    UIButton *button  =[UIButton buttonWithType:UIButtonTypeCustom];
    button.frame =  CGRectMake(100, 100, 200, 40);
    [button setTitle:@"sdfa" forState:UIControlStateNormal];
    button.backgroundColor = [UIColor flatOrangeColor];
    [button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
}

-(void)btnClick:(UIButton *)sender{
    [self toast:@"sjdfhkjsjf"];
    
    [sender startWithTime:5 title:@"结束了" countDownTitle:@"剩余时间" mainColor:GRJColor(100, 100, 100) countColor:[UIColor greenColor]];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.textF shake];
    
    [self.view endEditing:YES];
    
}


@end
